<template>
	<view class="content">
		<view class="input-group" v-if="hasLogin">
			<view class="input-row border content-background-color"  style="align-items: baseline;">
				<text class="title" >姓名：</text>
				<input class="m-input" :value="name" disabled="true" style="font-size: 18px;" />
			</view>
			<view class="input-row border content-background-color"  style="align-items: baseline;">
				<text class="title" >部门：</text>
				<input class="m-input" :value="deptName" disabled="true" style="font-size: 18px;width: 70%;" />
			</view>
			
		</view>
		<view class="btn-row">
			<button v-if="!hasLogin" type="primary" class="primary" @tap="bindLogin">登录</button>
			<button v-if="hasLogin" type="default" @tap="bindLogout">退出登录</button>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'

	export default {
		computed: {
			...mapState(['hasLogin', 'forcedLogin','name','deptName'])
		},
		methods: {
			...mapMutations(['logout']),
			bindLogin() {
				uni.navigateTo({
					url: '../login/login',
				});
			},
			bindLogout() {
				this.logout();
				/**
				 * 如果需要强制登录跳转回登录页面
				 */
				if (this.forcedLogin) {
					uni.reLaunch({
						url: '../login/login',
					});
				}
			}
		}
	}
</script>

<style>

</style>
